<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>猜拳小游戏</title>
    <script>
        /*0是石头，1是布，2是剪刀*/
        var cGuess,dGuess;
        function guessA() {
                cGuess=parseInt(1000*Math.random())%3;
                if (cGuess==0) {
                    document.getElementById("guess-a").innerHTML="看这个是玩家a的石头";
                }else if (cGuess==1){
                    document.getElementById("guess-a").innerHTML="看这个是玩家a的布";
                } else {
                    document.getElementById("guess-a").innerHTML="看这个是玩家a的剪刀";
                }
        }
        function guessB() {
            dGuess=parseInt(1000*Math.random())%3;
            if (dGuess==0) {
                document.getElementById("guess-b").innerHTML="看这个是玩家b的石头";
            }else if (dGuess==1){
                document.getElementById("guess-b").innerHTML="看这个是玩家b的布";
            } else {
                document.getElementById("guess-b").innerHTML="看这个是玩家b的剪刀";
            }
           /* if (cGuess==0&&dGuess==1||cGuess==1&&dGuess==2||cGuess==2&&dGuess==0){
                document.getElementById("result").innerHTML="恭喜你打败玩家a";
            }
            if (cGuess==1&&dGuess==0||cGuess==2&&dGuess==1||cGuess==0&&dGuess==2){
                document.getElementById("result").innerHTML="恭喜你被玩家a打败";
            }  if (cGuess==0&&dGuess==0||cGuess==1&&dGuess==1||cGuess==2&&dGuess==2){
                document.getElementById("result").innerHTML="这一次是平局啊";
            }*/
           if (cGuess==0){
               if (dGuess==0){
                  /* alert("这一次是平局啊")*/
                   document.getElementById("result").innerHTML="这一次是平局啊";
               }
               else if (dGuess==1){
                   /*alert("恭喜你打败玩家a")*/
                   document.getElementById("result").innerHTML="恭喜你打败玩家a";
               }
               else {
                 /*  alert("恭喜你被玩家a打败")*/
                   document.getElementById("result").innerHTML="恭喜你被玩家a打败";

               }
           }
           if (cGuess==1){
               if (dGuess==0){
                 /*  alert("恭喜你被玩家a打败")*/
                   document.getElementById("result").innerHTML="恭喜你被玩家a打败";}
               }
               else if (dGuess==1){
              /* alert("这一次是平局啊")*/
                   document.getElementById("result").innerHTML="这一次是平局啊";
               }
               else {
             /*  alert("恭喜你打败玩家a")*/
                   document.getElementById("result").innerHTML="恭喜你打败玩家a";

           } if (cGuess==2){
               if (dGuess==0){
                /*   alert("恭喜你打败玩家a")*/
                   document.getElementById("result").innerHTML="恭喜你打败玩家a";
               }
               else if (dGuess==1){
                  /* alert("恭喜你被玩家a打败")*/
                   document.getElementById("result").innerHTML="恭喜你被玩家a打败";
               }
               else {
                 /*  alert("这一次是平局啊")*/
                   document.getElementById("result").innerHTML="这一次是平局啊";
                   }
           }
        }
    </script>
    <style>
        body{
            background: url("wuxia/timg.jpg")no-repeat;
            width: 1085px;
            height: 409px;
            text-align: center;
        }
        h3{

        }
    </style>
</head>
<body>

<h3>猜拳游戏</h3>
    <!--玩家a-->
    <div >
        <button onclick="guessA()">玩家a</button>
        <p><div id="guess-a"></div></p>
    </div>
    <!--玩家b-->
    <div>
        <button onclick="guessB()">玩家b</button>
        <div id="guess-b"></div>
    </div>
    <p><div id="result"></div></p>
</body>
</html>